package seata.service.impl;


import cloud.seata.dao.StorageDao;
import cloud.seata.service.StorageService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import seata.dao.AccountDao;
import seata.service.AccountService;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.concurrent.TimeUnit;

@Service
public class AccountServiceImpl implements AccountService {
    private static final Logger LOGGER = LoggerFactory.getLogger(AccountServiceImpl.class);

    @Resource
    private AccountDao storageDao;

    /**
     * 扣减库存
     */
    @Override
    public void decrease(Long userId,BigDecimal money){
        LOGGER.info("------->storage-service中扣减库存开始");
        try{
            TimeUnit.SECONDS.sleep(20);
        }catch (Exception e){
            e.printStackTrace();
        }
        storageDao.decrease(userId,money);
        LOGGER.info("------->storage-service中扣减库存结束");
    }

}
